> ## Documentation Index
> Fetch the complete documentation index at: https://sequence-0fb8d9e6-api_docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# useGetSwapQuote

> Hook for fetching quotes for a swap

## Import

```tsx theme={null}
import { useGetSwapQuote } from '@0xsequence/hooks'
```

## Usage

```tsx theme={null}
import { useGetSwapQuote } from '@0xsequence/hooks'

function SwapComponent() {
  const { data: swapQuote, isLoading } = useGetSwapQuote({
    params: {
      walletAddress: '0x123...',
      fromTokenAddress: '0x456...',
      toTokenAddress: '0x789...',
      toTokenAmount: '1000000000000000000', // amount to buy in wei
      chainId: 1,
      includeApprove: true,
      slippageBps: 100 // 1% slippage
    }
  })

  if (isLoading) return <div>Loading...</div>

  return (
    <div>
      {swapQuote && (
        <div>
          Price: {swapQuote.price}
          Max Price: {swapQuote.maxPrice}
          Transaction Value: {swapQuote.transactionValue}
          <button onClick={() => executeSwap(swapQuote)}>Swap</button>
        </div>
      )}
    </div>
  )
}
```

## Return Type: `UseQueryResult<LifiSwapQuote>`

The hook returns all properties from React Query's `UseQueryResult` with swap quote data. Here's the detailed structure of the swapQuote.

```tsx theme={null}
interface LifiSwapQuote {
    currencyAddress: string;
    currencyBalance: string;
    price: string;
    maxPrice: string;
    to: string;
    transactionData: string;
    transactionValue: string;
    approveData: string;
    amount: string;
    amountMin: string;
}
```

### Properties

#### data

`SwapQuote | undefined`

The swap quote object containing:

* `currencyAddress`: Address of the currency to be swapped
* `currencyBalance`: Balance of the currency in the user's wallet
* `price`: The current price for the swap
* `maxPrice`: Maximum price allowed for the swap (includes slippage)
* `to`: The target contract address that handles the swap
* `transactionData`: Encoded transaction data for executing the swap
* `transactionValue`: The value to be sent with the transaction (for native tokens)
* `approveData`: Encoded approval transaction data (if includeApprove is true and needed)
* `amount`: The amount of currency to be received
* `amountMin`: The minimum amount to be received after slippage

#### isLoading

`boolean`

Loading state for the data fetch.

#### isError

`boolean`

Error state indicating if the query failed.

#### error

`Error | null`

Any error that occurred during data fetching.

## Parameters

The hook accepts two parameters:

### args: `GetLifiSwapQuoteArgs`

```tsx theme={null}
interface GetLifiSwapQuoteArgs {
  params: GetLifiSwapQuoteParams
}

interface GetLifiSwapQuoteParams {
    chainId: number;
    walletAddress: string;
    fromTokenAddress: string;
    toTokenAddress: string;
    fromTokenAmount?: string;
    toTokenAmount?: string;
    includeApprove: boolean;
    slippageBps: number;
}
```

| Parameter                 | Type      | Description                                         |
| ------------------------- | --------- | --------------------------------------------------- |
| `params.chainId`          | `number`  | The chain ID where the swap will occur              |
| `params.walletAddress`    | `string`  | The address of the user's wallet                    |
| `params.fromTokenAddress` | `string`  | The address of the token to sell                    |
| `params.toTokenAddress`   | `string`  | The address of the token to buy                     |
| `params.fromTokenAmount`  | `string`  | (Optional) The amount of token to sell (in wei)     |
| `params.toTokenAmount`    | `string`  | (Optional) The amount of token to buy (in wei)      |
| `params.includeApprove`   | `boolean` | Whether to include approval transaction data        |
| `params.slippageBps`      | `number`  | Maximum allowed slippage in basis points (100 = 1%) |

**Note**: You must provide either `fromTokenAmount` or `toTokenAmount`, but not both.

### options: `HooksOptions`

```tsx theme={null}
interface HooksOptions {
  disabled?: boolean
  retry?: boolean
}
```

| Parameter  | Type      | Description                                                   |
| ---------- | --------- | ------------------------------------------------------------- |
| `disabled` | `boolean` | (Optional) Disable the query from automatically running       |
| `retry`    | `boolean` | (Optional) Whether to retry failed queries (defaults to true) |
